from django.conf.urls import url, include
from web.views import account, home, project, manage

urlpatterns = [
    url(r'^send/sms/', account.send_sms, name='send_sms'),
    url(r'^register/', account.register, name='register'),
    url(r'^login/sms/', account.login_sms, name='login_sms'),
    url(r'^login/', account.login, name='login'),
    url(r'^img/code/', account.img_code, name='img_code'),
    url(r'^index/', home.index, name='index'),
    url(r'^logout/', account.logout, name='logout'),

    # 项目列表
    url(r'^project/list/', project.project_list, name='project_list'),
    # 通过正则分组命名的方式，传入项目类型和项目id参数 (注意用括号包裹)
    url(r'^project/star/(?P<project_type>\w+)/(?P<project_id>\d+)/', project.project_star, name='project_star'),
    # 项目星标取消操作
    # 写法1 通过当前操作者和项目创建者进行判断
    # url(r'^project/unstar/(?P<project_creator>\w+)/(?P<project_id>\d+)/', project.project_unstar, name='project_unstar'),

    # 写法2 通过项目类型进行判断
    url(r'^project/unstar/(?P<project_type>\w+)/(?P<project_id>\d+)/', project.project_unstar, name='project_unstar'),

    # 项目管理
    url(r'^manage/(?P<project_id>\d+)/', include([
        url(r'^dashboard/$', manage.dashboard, name='dashboard'),
        url(r'^issues/$', manage.issues, name='issues'),
        url(r'^statistics/$', manage.statistics, name='statistics'),
        url(r'^file/$', manage.file, name='file'),
        url(r'^wiki/$', manage.wiki, name='wiki'),
        url(r'^setting/$', manage.setting, name='setting')
    ]), None, None),

]
